import Vue from "vue";

const vue = Vue.prototype;

export default {
  namespaced: true,
  state: {
    questionItems: [],
    examPaper: {},
  },
  mutations: {
    SET_QUESTION_ITEMS(state, value) {
      state.questionItems = value;
    },
    SET_EXAM_PAPER(state, value) {
      state.examPaper = value;
    }
  },
  actions: {
    modifyExamPaper({commit}, value) {
      const url = "/examPapers/criteria";
      vue.axios.get(url, {
        params: {
          id: value.examPaperId,
          name: value.examPaperName,
        }
      }).then(resp => {
        commit('SET_EXAM_PAPER', resp.data);
      });
    },
    modifyQuestionItems({commit}, value) {
      const url = "/student/exam/items";
      vue.axios.get(url, {
        params: {
          examPaperId: value
        }
      }).then(resp => {
        commit("SET_QUESTION_ITEMS", resp.data);
      });
    },
  },
  getters: {},
}
